package action.chap6;

import action.chap4.Dish;
import action.chap4.DishUtils;

import java.util.List;

import static java.util.stream.Collectors.reducing;
import static java.util.stream.Collectors.summingInt;

public class Demo624 {
    public static void main(String[] args) {
        List<Dish> menus = DishUtils.getListDish();
        Integer collect = menus.stream().map(Dish::getCalories).reduce(Integer::sum).get();
        System.out.println(collect);
        // 方式2  mapToInt
        Integer collect1 = menus.stream().mapToInt(Dish::getCalories).sum();

        System.out.println(collect1);

    }
}
